package com.wootion.cims.general.config.validation;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

/**
 * @Author: LanQiang
 * @Date: 2022/11/07/17:33
 * @Description: 参数校验
 */
@Configuration
public class ValidatorConfig {
    /**
     * @description 只要属性中检查出一个不符合规则的参数，立马返回，就不要再往下进行了
     * @param
     * @author lanqiang
     * @date 2022/11/7 0007
     */
    @Bean
    public Validator validator() {
        ValidatorFactory validatorFactory = Validation
                .byProvider(HibernateValidator.class)
                .configure()
                .failFast(true)
                .buildValidatorFactory();
        return validatorFactory.getValidator();
    }
}
